package pro.shushi.pamirs.hr.core.action.eam;

import org.springframework.stereotype.Component;
import pro.shushi.pamirs.hr.api.model.eam.common.AbstractCopyModel;
import pro.shushi.pamirs.meta.annotation.Function;
import pro.shushi.pamirs.meta.annotation.Model;
import pro.shushi.pamirs.meta.annotation.fun.extern.Slf4j;
import pro.shushi.pamirs.meta.enmu.FunctionOpenEnum;
import pro.shushi.pamirs.meta.enmu.FunctionTypeEnum;

/**
 * @description:
 * @author: shushi
 */
@Slf4j
@Component
@Model.model(AbstractCopyModel.MODEL_MODEL)
public class AbstractCopyModelAction {

    @Function(openLevel = FunctionOpenEnum.API)
    @Function.Advanced(type = FunctionTypeEnum.QUERY, displayName = "复制")
    public AbstractCopyModel copy(AbstractCopyModel data) {
        if (data.getId() != null) {
            data = data.queryById();
            data.unsetId();
            data.unsetCreateDate();
            data.unsetWriteDate();
            data.unsetCreateUid();
            data.unsetWriteUid();
        }

        return data;
    }

}
